<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/** 
<span class='line'>  2</span>  * (smt)2 simple mouse tracking - record mode (smt-record-2.0.0.js)
<span class='line'>  3</span>  * Copyleft (cc) 2006-2009 Luis Leiva
<span class='line'>  4</span>  * Release date: September 12th 2009 
<span class='line'>  5</span>  * http://smt.speedzinemedia.com
<span class='line'>  6</span>  * @class smt2-record
<span class='line'>  7</span>  * @requires smt2-aux Auxiliary (smt)2 functions  
<span class='line'>  8</span>  * @version 2.0.0
<span class='line'>  9</span>  * @author Luis Leiva 
<span class='line'> 10</span>  * @license Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. 
<span class='line'> 11</span>  * @see smtAuxFn
<span class='line'> 12</span>  */</span><span class="WHIT">
<span class='line'> 13</span> 
<span class='line'> 14</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">smtRecord</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 15</span> </span><span class="WHIT">  </span><span class="COMM">/** 
<span class='line'> 16</span>    * (smt)2 default recording options.
<span class='line'> 17</span>    * For developers: This Object can be overriden at runtime by calling the function {@link smtAuxFn#overrideTrackingOptions}.
<span class='line'> 18</span>    * For users: create the Object "smtRecordingOptions" and assign your custom values for the following properties.   
<span class='line'> 19</span>    * @see smtAuxFn#overrideTrackingOptions
<span class='line'> 20</span>    */</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">smtOpt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 23</span>      * Tracking frequency, in frames per second.
<span class='line'> 24</span>      * @type number           
<span class='line'> 25</span>      */</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT">    </span><span class="NAME">fps</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">24</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 28</span>      * Tracking timeout, in seconds. 
<span class='line'> 29</span>      * If timeout is reached, mouse activity is not recorded.
<span class='line'> 30</span>      * @type number     
<span class='line'> 31</span>      */</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">    </span><span class="NAME">recTime</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">120</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 34</span>      * Path to (smt)2 installation.
<span class='line'> 35</span>      * The record script will try to find automatically the installation path, 
<span class='line'> 36</span>      * but if you used other name (i.e: http://my.server/test) 
<span class='line'> 37</span>      * you must type it explicitly here. Please do NOT place a final slash (/).      
<span class='line'> 38</span>      * Valid path names that will be recognized automatically are: "http://domain.name/smt2", "/my/smt2dir", "/server/t/tracksmt2" ... and so on.
<span class='line'> 39</span>      * @type string     
<span class='line'> 40</span>      */</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">    </span><span class="NAME">smtPath</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"/smt2"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 43</span>      * You may choose to advice users (or not) that their mouse activity is going to be logged.
<span class='line'> 44</span>      * @type boolean      
<span class='line'> 45</span>      */</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">    </span><span class="NAME">warn</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 48</span>      * Text to display when advising users (if warn: true).
<span class='line'> 49</span>      * @type string     
<span class='line'> 50</span>      */</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">    </span><span class="NAME">warnText</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"We'd like to track your mouse activity\nin order to improve this website's usability.\nDo you agree?"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 53</span>      * Cookies lifetime (in days) to reset both first time users and agreed-to-track visitors.
<span class='line'> 54</span>      * @type int     
<span class='line'> 55</span>      */</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">    </span><span class="NAME">cookieDays</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">365</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 58</span>      * Custom initialization routines. Here you can add more functionalities on init.
<span class='line'> 59</span>      * @type function     
<span class='line'> 60</span>      */</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">    </span><span class="NAME">initFn</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 63</span>      * Random user selection: if true, (smt)2 is not initialized.
<span class='line'> 64</span>      * Setting it to false (or 0) means that all the population will be tracked.
<span class='line'> 65</span>      * You should use random sampling for accurate statistical analysis.     
<span class='line'> 66</span>      * @type int           
<span class='line'> 67</span>      */</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">    </span><span class="NAME">disabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="COMM">//Math.round(Math.random()) // &lt;-- random sampling</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">    </span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">  </span><span class="COMM">/* do not edit below this line -------------------------------------------- */</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">  </span><span class="COMM">// get auxiliar functions</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">aux</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.smtAuxFn</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">aux</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">"auxiliar (smt)2 functions not found"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 78</span> 
<span class='line'> 79</span> </span><span class="WHIT">  </span><span class="COMM">// get user options, if set</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">custom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.smtRecordingOptions</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">custom</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">aux.overrideTrackingOptions</span><span class="PUNC">(</span><span class="NAME">smtOpt</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">custom</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">  </span><span class="COMM">// try to auto-detect smt2 installation path                  </span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">scripts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">'script'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scripts.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">filename</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scripts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">src</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="REGX">/smt-record/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">filename</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">paths</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">filename.split</span><span class="PUNC">(</span><span class="STRN">"/"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.array.indexOf</span><span class="PUNC">(</span><span class="NAME">paths</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"smt2"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">smtOpt.smtPath</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">        </span><span class="NAME">smtOpt.smtPath</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">paths.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">"/"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">  </span><span class="COMM">/* (smt)2 record system definition ---------------------------------------- */</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">  </span><span class="COMM">/** 
<span class='line'>101</span>    * (smt)2 recording object.
<span class='line'>102</span>    * This Object is private. Methods are cited but not documented.
<span class='line'>103</span>    */</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">smtRec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">    </span><span class="NAME">i</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">                                         </span><span class="COMM">// counter var</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">    </span><span class="NAME">mouse</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">                       </span><span class="COMM">// mouse position</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">    </span><span class="NAME">viewport</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">width</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">              </span><span class="COMM">// data normalization</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">    </span><span class="NAME">discrepance</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">:</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">                    </span><span class="COMM">// discrepance ratios</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">    </span><span class="NAME">coords</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">                     </span><span class="COMM">// saved position coords</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">    </span><span class="NAME">clicks</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">                     </span><span class="COMM">// saved click coords</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">    </span><span class="NAME">elem</span><span class="PUNC">:</span><span class="WHIT">     </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">hovered</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">clicked</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">         </span><span class="COMM">// clicked and hovered elements</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">    </span><span class="NAME">url</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">                               </span><span class="COMM">// document URL</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">    </span><span class="NAME">rec</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">                               </span><span class="COMM">// recording identifier</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">    </span><span class="NAME">userId</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">                               </span><span class="COMM">// user session identifier</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">    </span><span class="NAME">append</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">                               </span><span class="COMM">// append data identifier</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">    </span><span class="NAME">paused</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">                              </span><span class="COMM">// check active window</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">    </span><span class="NAME">clicked</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">                              </span><span class="COMM">// no mouse click yet</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">    </span><span class="NAME">timeout</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">smtOpt.fps</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtOpt.recTime</span><span class="PUNC">,</span><span class="WHIT">        </span><span class="COMM">// tracking timeout</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">    </span><span class="NAME">xmlhttp</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">aux.createXMLHTTPObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">          </span><span class="COMM">// create XHR object</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">    </span><span class="NAME">firstTimeUser</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">                            </span><span class="COMM">// assume a first time user initially</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">    </span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>123</span>      * Pauses recording. 
<span class='line'>124</span>      * The mouse activity is tracked only when the current window has focus. 
<span class='line'>125</span>      */</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">    </span><span class="NAME">pauseRecording</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.paused</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>131</span>      * Resumes recording. The current window gain focus.
<span class='line'>132</span>      */</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">    </span><span class="NAME">resumeRecording</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.paused</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>138</span>      * Normalizes data on window resizing.
<span class='line'>139</span>      */</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">    </span><span class="NAME">normalizeData</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">vp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.getWindowSize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">      </span><span class="COMM">// compute new discrepace ratio</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.discrepance.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.roundTo</span><span class="PUNC">(</span><span class="NAME">vp.width</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">smtRec.viewport.width</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.discrepance.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.roundTo</span><span class="PUNC">(</span><span class="NAME">vp.height</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">smtRec.viewport.height</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>148</span>      * Cross-browser way to register the mouse position.
<span class='line'>149</span>      * @autor Peter-Paul Koch (quirksmode.org)
<span class='line'>150</span>      */</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">    </span><span class="NAME">getMousePos</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.event</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">    	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.pageX</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">e.pageY</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">    		</span><span class="NAME">smtRec.mouse.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e.pageX</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">    		</span><span class="NAME">smtRec.mouse.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e.pageY</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">    	</span><span class="PUNC">}</span><span class="WHIT">	</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.clientX</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">e.clientY</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">    		</span><span class="NAME">smtRec.mouse.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e.clientX</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">document.body.scrollLeft</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">document.documentElement.scrollLeft</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">    		</span><span class="NAME">smtRec.mouse.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e.clientY</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">document.body.scrollTop</span><span class="WHIT">  </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">document.documentElement.scrollTop</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">    	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>163</span>      * Registers single clicks and drag and drop operations.
<span class='line'>164</span>      */</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">    </span><span class="NAME">setClick</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.clicked</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>170</span>      * User releases the mouse.
<span class='line'>171</span>      */</span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">    </span><span class="NAME">releaseClick</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>173</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>174</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.clicked</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>177</span>      * (smt)2 recording loop.
<span class='line'>178</span>      * Tracks mouse coords when they're inside the client window, 
<span class='line'>179</span>      * so zero and null values are not taken into account.     
<span class='line'>180</span>      */</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">    </span><span class="NAME">recMouse</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">      </span><span class="COMM">// track mouse only if window is active (has focus)</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtRec.paused</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">      </span><span class="COMM">// get mouse coords until timeout is reached </span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtRec.i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">smtRec.timeout</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">        </span><span class="COMM">// get normalized coords</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NAME">smtRec.discrepance.x</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRec.mouse.x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NAME">smtRec.discrepance.y</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRec.mouse.y</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">          </span><span class="NAME">smtRec.coords.x.push</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">          </span><span class="NAME">smtRec.coords.y.push</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">          </span><span class="COMM">// track also mouse clicks</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">smtRec.clicked</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">            </span><span class="NAME">smtRec.clicks.x.push</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">            </span><span class="NAME">smtRec.clicks.y.push</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">            </span><span class="NAME">smtRec.clicks.x.push</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">            </span><span class="NAME">smtRec.clicks.y.push</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">    	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">    	  </span><span class="COMM">// timeout reached</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">    	  </span><span class="NAME">clearInterval</span><span class="PUNC">(</span><span class="NAME">smtRec.rec</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">    	  </span><span class="NAME">clearInterval</span><span class="PUNC">(</span><span class="NAME">smtRec.append</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">    	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT">    	</span><span class="COMM">// next step</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT">    	</span><span class="PUNC">++</span><span class="NAME">smtRec.i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>211</span>      * Sends data in background via an XHR object (asynchronous request).
<span class='line'>212</span>      * This function starts the tracking session.
<span class='line'>213</span>      */</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">    </span><span class="NAME">initMouseData</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.updateViewPort</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">      </span><span class="COMM">// prepare data</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">data</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"url="</span><span class="WHIT">        </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.url</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&urltitle="</span><span class="WHIT">  </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">document.title</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&bname="</span><span class="WHIT">     </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">aux.browserDetect.browser</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&bversion="</span><span class="WHIT">  </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">aux.browserDetect.version</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&bos="</span><span class="WHIT">       </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">aux.browserDetect.OS</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&bua="</span><span class="WHIT">       </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">navigator.userAgent</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&screenw="</span><span class="WHIT">   </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">screen.width</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&screenh="</span><span class="WHIT">   </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">screen.height</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&vpw="</span><span class="WHIT">       </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.viewport.width</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&vph="</span><span class="WHIT">       </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.viewport.height</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&time="</span><span class="WHIT">      </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">aux.roundTo</span><span class="PUNC">(</span><span class="NAME">smtRec.i</span><span class="PUNC">/</span><span class="NAME">smtOpt.fps</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&fps="</span><span class="WHIT">       </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtOpt.fps</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&ftu="</span><span class="WHIT">       </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.firstTimeUser</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&xcoords="</span><span class="WHIT">   </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.coords.x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&ycoords="</span><span class="WHIT">   </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.coords.y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&xclicks="</span><span class="WHIT">   </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.clicks.x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&yclicks="</span><span class="WHIT">   </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.clicks.y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&elhovered="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.elem.hovered</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&elclicked="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.elem.clicked</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">      </span><span class="COMM">// send request</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">      </span><span class="NAME">aux.sendAjaxRequest</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">        </span><span class="NAME">url</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="NAME">smtOpt.smtPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/core/store.php"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">        </span><span class="NAME">callback</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">smtRec.setUserId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">        </span><span class="NAME">postdata</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">        </span><span class="NAME">xmlhttp</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">smtRec.xmlhttp</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">      </span><span class="COMM">// clean</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.clearMouseData</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>248</span>      * Sets the user ID.
<span class='line'>249</span>      * @return void
<span class='line'>250</span>      * @param {string} response  XHR response text
<span class='line'>251</span>      */</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">    </span><span class="NAME">setUserId</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">response</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.userId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">response</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtRec.userId</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">        </span><span class="COMM">// once the session started, append mouse data</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">        </span><span class="NAME">smtRec.append</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">setInterval</span><span class="PUNC">(</span><span class="NAME">smtRec.appendMouseData</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2000</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>261</span>      * Sends data (POST) in asynchronously mode via an XHR object.
<span class='line'>262</span>      * This appends the mouse data to the current tracking session.
<span class='line'>263</span>      * If user Id is not set, mouse data are queued.     
<span class='line'>264</span>      */</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'>265</span> </span><span class="WHIT">    </span><span class="NAME">appendMouseData</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">smtRec.rec</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">smtRec.paused</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">      </span><span class="COMM">// prepare data</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">data</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"uid="</span><span class="WHIT">        </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.userId</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&time="</span><span class="WHIT">      </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">aux.roundTo</span><span class="PUNC">(</span><span class="NAME">smtRec.i</span><span class="PUNC">/</span><span class="NAME">smtOpt.fps</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&xcoords="</span><span class="WHIT">   </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.coords.x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&ycoords="</span><span class="WHIT">   </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.coords.y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&xclicks="</span><span class="WHIT">   </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.clicks.x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&yclicks="</span><span class="WHIT">   </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.clicks.y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&elhovered="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.elem.hovered</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">          </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"&elclicked="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">smtRec.elem.clicked</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">      </span><span class="COMM">// send request</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">      </span><span class="NAME">aux.sendAjaxRequest</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">        </span><span class="NAME">url</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="NAME">smtOpt.smtPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/core/append.php"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">        </span><span class="NAME">postdata</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">        </span><span class="NAME">xmlhttp</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">smtRec.xmlhttp</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">      </span><span class="COMM">// clean</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.clearMouseData</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>287</span>      * Clears mouse data from queue.        
<span class='line'>288</span>      */</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">    </span><span class="NAME">clearMouseData</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.coords.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.coords.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.clicks.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.clicks.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.elem.hovered</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.elem.clicked</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>299</span>      * Finds hovered or clicked DOM element.     
<span class='line'>300</span>      */</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">    </span><span class="NAME">findElement</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.event</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">      </span><span class="COMM">// bind function to widget tracking object</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">      </span><span class="NAME">aux.widget.findDOMElement</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"mousedown"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">          </span><span class="NAME">smtRec.elem.clicked.push</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"mousemove"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">          </span><span class="NAME">smtRec.elem.hovered.push</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>314</span>      * Updates viewport size.     
<span class='line'>315</span>      */</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT">    </span><span class="NAME">updateViewPort</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>317</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">vp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.getWindowSize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>319</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.viewport.width</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">vp.width</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>320</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.viewport.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">vp.height</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>321</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>322</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>323</span>      * System initialization.
<span class='line'>324</span>      * Assigns events and performs other initialization routines.     
<span class='line'>325</span>      */</span><span class="WHIT">
<span class='line'>326</span> </span><span class="WHIT">    </span><span class="NAME">init</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>327</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT">      </span><span class="COMM">// compute the viewport here because of IE</span><span class="WHIT">
<span class='line'>329</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.updateViewPort</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>330</span> </span><span class="WHIT">      </span><span class="COMM">// get this location BEFORE making the AJAX request</span><span class="WHIT">
<span class='line'>331</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.url</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.location.href</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>332</span> </span><span class="WHIT">      </span><span class="COMM">// set main function: the (smt)2 recording interval</span><span class="WHIT">
<span class='line'>333</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">interval</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NUMB">1000</span><span class="PUNC">/</span><span class="NAME">smtOpt.fps</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">      </span><span class="NAME">smtRec.rec</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">setInterval</span><span class="PUNC">(</span><span class="NAME">smtRec.recMouse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">interval</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">      </span><span class="COMM">// allow mouse tracking over Flash animations</span><span class="WHIT">
<span class='line'>336</span> </span><span class="WHIT">      </span><span class="NAME">aux.allowTrackingOnFlashObjects</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>337</span> </span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>338</span> </span><span class="WHIT">      </span><span class="COMM">// add unobtrusive events</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">      </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">document</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"mousemove"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtRec.getMousePos</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">        </span><span class="COMM">// get mouse coords</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT">      </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">document</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"mousedown"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtRec.setClick</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">           </span><span class="COMM">// mouse is clicked        </span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT">      </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">document</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"mouseup"</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="NAME">smtRec.releaseClick</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">       </span><span class="COMM">// mouse is released</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">      </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">window</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="STRN">"resize"</span><span class="PUNC">,</span><span class="WHIT">    </span><span class="NAME">smtRec.normalizeData</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">      </span><span class="COMM">// make easy data interpretation</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">      </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">window</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="STRN">"blur"</span><span class="PUNC">,</span><span class="WHIT">      </span><span class="NAME">smtRec.pauseRecording</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">     </span><span class="COMM">// only record mouse when browser window is active</span><span class="WHIT">
<span class='line'>344</span> </span><span class="WHIT">      </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">window</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="STRN">"focus"</span><span class="PUNC">,</span><span class="WHIT">     </span><span class="NAME">smtRec.resumeRecording</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>345</span> </span><span class="WHIT">      </span><span class="COMM">// track also at the widget level (fine-grained mouse tracking)</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT">      </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">document</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"mousedown"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtRec.findElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">        </span><span class="COMM">// elements clicked</span><span class="WHIT">
<span class='line'>347</span> </span><span class="WHIT">      </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">document</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"mousemove"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtRec.findElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">        </span><span class="COMM">// elements hovered</span><span class="WHIT">
<span class='line'>348</span> </span><span class="WHIT">      </span><span class="COMM">// flush mouse data when tracking ends</span><span class="WHIT">
<span class='line'>349</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">window.onbeforeunload</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>350</span> </span><span class="WHIT">        </span><span class="COMM">// user closes the browser window</span><span class="WHIT">
<span class='line'>351</span> </span><span class="WHIT">        </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">window</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"beforeunload"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtRec.appendMouseData</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>352</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">        </span><span class="COMM">// page is unloaded (for old browsers)</span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT">        </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">window</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"unload"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtRec.appendMouseData</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>355</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>356</span> </span><span class="WHIT">      </span><span class="COMM">// this is the fully-cross-browser method to store tracking data successfully</span><span class="WHIT">
<span class='line'>357</span> </span><span class="WHIT">      </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="NAME">smtRec.initMouseData</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2000</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>358</span> </span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">      </span><span class="COMM">// call user-defined init function</span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtOpt.initFn</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">smtOpt.initFn</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>361</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>362</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>363</span> 
<span class='line'>364</span> </span><span class="WHIT">  </span><span class="COMM">/* (smt)2 record initialization ------------------------------------------- */</span><span class="WHIT">
<span class='line'>365</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>366</span> </span><span class="WHIT">  </span><span class="COMM">// does user browse for the first time?</span><span class="WHIT">
<span class='line'>367</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">previousUser</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.cookies.checkCookie</span><span class="PUNC">(</span><span class="STRN">'isFirstTimeUser'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>368</span> </span><span class="WHIT">  </span><span class="COMM">// do not skip first time users when current visit is not sampled (smt disabled)</span><span class="WHIT">
<span class='line'>369</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtOpt.disabled</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">previousUser</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>370</span> </span><span class="WHIT">  </span><span class="COMM">// check if warning is enabled</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtOpt.warn</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>372</span> </span><span class="WHIT">    </span><span class="COMM">// did she agree for tracking before?</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">prevAgreed</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.cookies.checkCookie</span><span class="PUNC">(</span><span class="STRN">'isAgreedToTrack'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT">    </span><span class="COMM">// if user is adviced, she must agree</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">agree</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">prevAgreed</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">aux.cookies.getCookie</span><span class="PUNC">(</span><span class="STRN">'isAgreedToTrack'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">window.confirm</span><span class="PUNC">(</span><span class="NAME">smtOpt.warnText</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">agree</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT">      </span><span class="COMM">// will ask next day (instead of smtOpt.cookieDays value)</span><span class="WHIT">
<span class='line'>378</span> </span><span class="WHIT">      </span><span class="NAME">aux.cookies.setCookie</span><span class="PUNC">(</span><span class="STRN">'isAgreedToTrack'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>379</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">      </span><span class="NAME">aux.cookies.setCookie</span><span class="PUNC">(</span><span class="STRN">'isAgreedToTrack'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtOpt.cookieDays</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>383</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>384</span> </span><span class="WHIT">  </span><span class="COMM">// store int numbers, not booleans</span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT">  </span><span class="NAME">smtRec.firstTimeUser</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">previousUser</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// yes, it's a bitwise operation</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT">  </span><span class="NAME">aux.cookies.setCookie</span><span class="PUNC">(</span><span class="STRN">'isFirstTimeUser'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtRec.firstTimeUser</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtOpt.cookieDays</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>387</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT">  </span><span class="COMM">// launch browser detection script (for statistical/debugging purposes)</span><span class="WHIT">
<span class='line'>389</span> </span><span class="WHIT">  </span><span class="NAME">aux.browserDetect.init</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>390</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">  </span><span class="COMM">// start recording on DOM loaded</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">  </span><span class="NAME">aux.onDOMload</span><span class="PUNC">(</span><span class="NAME">smtRec.init</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>394</span> </span><span class="PUNC">}</span></pre></body></html>